/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package manager;
import Entity.Department;
import iface.IManager;
import java.util.ArrayList;
/**
 *
 * @author BinhNV_A04911
 */
public class DepartmentManager implements IManager<Department> {

    private ArrayList<Department> DepartmenList;

    public DepartmentManager(){
        this.DepartmenList = new ArrayList<Department>();
    }
    public boolean add(Department obj) {
       return this.DepartmenList.add(obj);
    }

    public boolean remove(Department obj) {
     return this.DepartmenList.remove(obj);
    }

    public Department replace(int index, Department obj) {
       return this.DepartmenList.set(index, obj);
    }
    public int size() {
       return this.DepartmenList.size();
    }

    public Department get(int index) {
       return this.DepartmenList.get(index);
    }

    public Department getById(int id) {
       for(Department objDepartment:this.DepartmenList){
           if(Integer.valueOf(objDepartment.getDepartmentID())==id){
               return objDepartment;
           }
       }
       return null;
    }

    public Department getByName(String name) {
       for(Department obj:this.DepartmenList){
           if(obj.getDepartmentName().equals(obj)){
               return obj;
           }
       }
       return null;
    }

    public void setVisible(Department obj, boolean value) {
      for(Department objDepartment:this.DepartmenList){
          if(obj.getDepartmentName().equals(objDepartment.getDepartmentID())){
              objDepartment.setStatus(value);
              break;
          }
      }
    }

}
